-- cring vsb thing: -- local owner = owner ---------------------- -- Services local TweenS = game:service("TweenService") ------------- -- UTILS -- local Utils = {} function Utils:Create(InstData, Props) local Obj = Instance.new(InstData[1], InstData[2]) for k, v in pairs (Props) do Obj[k] = v end; return Obj end function Utils:CNR(cf) -- CFrameNoRotate return CFrame.new(cf.x,cf.y,cf.z) end -- LEGACY FUNCTIONS WITH ADDED FEATURES function Utils:ezweld(p, a, b, cf, c1) local weld = Instance.new("Weld",p) weld.Part0 = a weld.Part1 = b weld.C0 = cf if c1 then weld.C1 = c1 end return weld end function Utils:NewSound(p, id, pit, vol, loop, autoplay) local Sound = Instance.new("Sound",p) Sound.Pitch = pit Sound.Volume = vol Sound.SoundId = "rbxassetid://" ..id Sound.Looped = loop if autoplay then Sound:Play() end return Sound end ----------- --[[ local root = Utils:Create({"Part", script}, { Size = Vector3.new(2, 2, 1), Transparency = .5, CFrame = owner.Character.Head.CFrame, CustomPhysicalProperties = PhysicalProperties.new(0, 0, 0, 10000, 10000), Name = "HumanoidRootPart" });]] local dude = game.Players:CreateHumanoidModelFromDescription(Utils:Create({"HumanoidDescription"}, { HeadColor = BrickColor.Yellow().Color, RightArmColor = BrickColor.Yellow().Color, LeftArmColor = BrickColor.Yellow().Color, }), Enum.HumanoidRigType.R6) dude.Parent = script dude.Humanoid:Destroy() Utils:Create({"AnimationController", dude}, { Name = "Humanoid" }); Instance.new("Animator", dude.Humanoid) local root = dude.HumanoidRootPart root.CFrame = owner.Character.Head.CFrame local ROT = Utils:Create({"BodyGyro", root}, { Name = "rotate", MaxTorque = Vector3.one * 70000, D = 115, }); root:SetNetworkOwner(owner) owner.Character = dude local fat = Utils:Create({"Part", dude}, { Name = "fat", Size = Vector3.new(2, 3, 1), Massless = true, Transparency = 1 }); Utils:ezweld(fat, fat, root, CFrame.new()) local bevels = { Torso = "rbxasset://fonts/torso.mesh", ["Right Arm"] = "rbxasset://fonts/rightarm.mesh", ["Left Arm"] = "rbxasset://fonts/leftarm.mesh", ["Right Leg"] = "rbxasset://fonts/rightleg.mesh", ["Left Leg"] = "rbxasset://fonts/leftleg.mesh", } for i,v in pairs (dude:children()) do if v:IsA("BasePart") then v.CustomPhysicalProperties = PhysicalProperties.new(.5, 0, 0, 10000, 10000) v:SetNetworkOwner(owner) end if bevels[v.Name] then Utils:Create({"SpecialMesh", v}, { MeshId = bevels[v.Name] }) end end -- ls local ls = NLS([[ local UIS = game:service("UserInputService") local root = script.base.Value local gyro = root.rotate local height = 3 --local hum = root.ch.hum -- add anims local Utils = {} function Utils:Create(InstData, Props) local Obj = Instance.new(InstData[1], InstData[2]) for k, v in pairs (Props) do Obj[k] = v end; return Obj end local hum = root.Parent.Humanoid local anims = { Idle = hum:LoadAnimation(Utils:Create({"Animation"}, {AnimationId = "rbxassetid://180435571"})), Walk = hum:LoadAnimation(Utils:Create({"Animation"}, {AnimationId = "rbxassetid://180426354"})), Jump = hum:LoadAnimation(Utils:Create({"Animation"}, {AnimationId = "rbxassetid://125750702"})), Fall = hum:LoadAnimation(Utils:Create({"Animation"}, {AnimationId = "rbxassetid://180436148"})), Climb = hum:LoadAnimation(Utils:Create({"Animation"}, {AnimationId = "rbxassetid://180436334"})) } anims.Idle:AdjustWeight(9, 0.100000001) anims.Walk:AdjustWeight(10, 0.100000001) anims.Jump:AdjustWeight(10, 0.100000001) anims.Fall:AdjustWeight(10, 0.100000001) local jumpAnimDuration = 0.175 -- from the anim script itself local jumpTime = 0 -- funcs local BADS = {} local param = RaycastParams.new() param.FilterDescendantsInstances = {root.Parent, root, BADS} param.IgnoreWater = true local function goodray(a, b, keeptries) if not keeptries then tries = 0 else tries = tries + 1 end local ray = workspace:Raycast(a, b, param) if ray and ray.Instance and not ray.Instance.CanCollide then table.insert(BADS, ray.Instance) param.FilterDescendantsInstances = BADS if tries < 20 then return goodray(a, b, true) else return ray end end return ray end local function fground() -- find ground return goodray(root.CFrame.p - Vector3.new(0, height/2-.1), -Vector3.yAxis * ((height/2) + .2)) end local function ftruss(keeptries) -- find truss local lol = goodray(root.CFrame.p - Vector3.new(0, height-.1), root.CFrame.lookVector * .65) if lol and lol.Instance and lol.Instance.IsA and lol.Instance:IsA("TrussPart") then return lol end end -- vars local ground = nil local grndi = nil -- ground inst local movedir local typing = false local cam = workspace.CurrentCamera; cam.CameraSubject = root local camlook = Vector3.zero local walkvelo = Vector3.zero local speed = 16 -- walkspeed local jump = 50 -- jumppower local climbing = false local swimming = false local swimang = CFrame.new() -- moves local bv = Instance.new("BodyVelocity") bv.MaxForce = Vector3.new(0, 1, 0) * 1000000 bv.Velocity = Vector3.zero local cbv = Instance.new("BodyVelocity") cbv.MaxForce = Vector3.one * 100000000 cbv.Velocity = Vector3.zero local jumping local wasground local MOVES = { jump = function() if (ground or swimming) and UIS:IsKeyDown("Space") then bv.Parent = nil jumping = true root.Velocity = Vector3.new(root.Velocity.x, jump, root.Velocity.z) if not swimming then root.CFrame = root.CFrame * CFrame.new(0, .1, 0) else root.CFrame = root.CFrame + Vector3.new(0, .1, 0) end elseif climbing and UIS:IsKeyDown("Space") then bv.Parent = nil jumping = true climbing = false root.Velocity = root.CFrame.lookVector * -jump + Vector3.new(0, jump / 1.5) root.CFrame = root.CFrame + -root.CFrame.lookVector * .1 end end } -- controls UIS.InputBegan:connect(function(i, t) typing = t end) -- loops game:service("RunService").Stepped:connect(function(_, dt) local _,y = cam.CFrame:ToEulerAnglesYXZ() camlook = CFrame.Angles(0, y, 0).lookVector -- pc movedir if not typing then movedir = Vector3.zero if UIS:IsKeyDown("W") then movedir = movedir + camlook end; if UIS:IsKeyDown("S") then movedir = movedir - camlook end; if UIS:IsKeyDown("D") then movedir = movedir + CFrame.Angles(0, y, 0).rightVector end; if UIS:IsKeyDown("A") then movedir = movedir - CFrame.Angles(0, y, 0).rightVector end; end; if movedir.magnitude > 0 then -- normalize and turn movedir = movedir / movedir.magnitude if not climbing and not swimming then if ground then gyro.CFrame = gyro.CFrame:lerp(CFrame.new(Vector3.zero, movedir), math.min(.2 * dt * 60, 1)) -- was .225 else gyro.CFrame = gyro.CFrame:lerp(CFrame.new(Vector3.zero, movedir), math.min(.125 * dt * 60, 1)) end end end walkvelo = movedir * speed -- check moves for i,v in pairs (MOVES) do if not typing then v() end end -- climb truss = ftruss() if truss then if fground() then root.CFrame = root.CFrame * CFrame.new(0, .075, 0) end climbing = true cbv.Parent = root local dire = Vector3.zero if not typing then dire = Vector3.new(0, UIS:IsKeyDown("W") and speed or UIS:IsKeyDown("S") and -speed or 0) end bv.Parent = nil --bv.Parent = root; bv.Velocity = dire cbv.Velocity = dire --root.Velocity = (root.CFrame.lookVector * 3) + cbv.Velocity else climbing = false end if ground then climbing = false; cbv.Parent = nil end -- water support local reg = Region3.new(root.CFrame.p-Vector3.one/2, root.CFrame.p+Vector3.one/2) reg = reg:ExpandToGrid(4) local terrain = workspace.Terrain:ReadVoxels(reg, 4) if terrain[1][1][1].Name == "Water" and not climbing and (not ground or ground.Material.Name ~= "Water") then ground = false swimming = true local yvel = cam.CFrame.lookVector.y * speed / 1.5 * movedir.magnitude + (16 / 10) bv.Parent = root; bv.Velocity = bv.Velocity:lerp(Vector3.new(0, yvel), math.min(.4 * dt * 60, 1)) root.Velocity = root.Velocity:lerp(Vector3.new(walkvelo.x, yvel, walkvelo.z), math.min(.75 * dt * 60, 1)) local lolol = CFrame.new(Vector3.zero, movedir+Vector3.new(0, cam.CFrame.lookVector.y*movedir.magnitude)) if movedir.magnitude <= 0 then lolol = swimang else swimang = swimang:lerp(CFrame.new(Vector3.zero, movedir) ,math.min(.2 * dt * 60, 1)) end gyro.CFrame = gyro.CFrame:lerp(lolol*CFrame.Angles(-(math.pi/2)*movedir.magnitude, 0, 0), math.min(.2 * dt * 60, 1)) else swimming = false end -- ground detect stuff ground = fground() if not climbing and not swimming then cbv.Parent = nil; bv.Velocity = Vector3.zero if ground and (not jumping) then bv.Parent = root; jumping = false root.CFrame = root.CFrame:lerp(root.CFrame + (-root.CFrame.p + Vector3.new(root.CFrame.x, ground.Position.y + height, root.CFrame.z)), math.min(.5 * dt * 60, 1)) -- ground frc root.Velocity = root.Velocity:lerp(Vector3.new(walkvelo.x, root.Velocity.y, walkvelo.z), math.min(.75 * dt * 60, 1)) local ve = ground.Instance.Velocity if ve.magnitude > 0 then root.Velocity = ve + walkvelo if math.abs(ve.y) > 0 then bv.Parent = nil root.CFrame = root.CFrame * CFrame.new(0, .015, 0) end end else bv.Parent = nil -- air frc root.Velocity = root.Velocity:lerp(Vector3.new(walkvelo.x, root.Velocity.y, walkvelo.z), math.min(.125 * dt * 60, 1)) -- was .15 if not UIS:IsKeyDown("Space") then jumping = false end end end wasground = ground -- silly silly broken bodyvelocity support for i,v in pairs (root.Parent:GetDescendants()) do if v:IsA("BodyVelocity") and v.MaxForce.magnitude > 0 and v ~= bv then local mult = (v.MaxForce / v.MaxForce.magnitude) local xmult, ymult, zmult = (root.Velocity.x / 100 < v.Velocity.x) and 100 or 1, (root.Velocity.y / 100 < v.Velocity.y) and 100 or 1, (root.Velocity.z / 100 < v.Velocity.z) and 100 or 1 --print(v.Velocity.x, v.Velocity.y, v.Velocity.z, v.MaxForce) --root.Velocity = root.Velocity:lerp(Vector3.new(math.max(root.Velocity.x / 100, v.Velocity.x) * xmult, 0, 0), math.min(v.MaxForce.x / 400, 1)) --root.Velocity = root.Velocity:lerp(Vector3.new(math.max(root.Velocity.y / 100, v.Velocity.y) * ymult, 0, 0), math.min(v.MaxForce.y / 400, 1)) --root.Velocity = root.Velocity:lerp(Vector3.new(math.max(root.Velocity.z / 100, v.Velocity.z) * zmult, 0, 0), math.min(v.MaxForce.z / 400, 1)) root.Velocity = root.Velocity:lerp(Vector3.new(v.Velocity.x, root.Velocity.y, root.Velocity.z), math.clamp(v.MaxForce.x, 0, 1)) root.Velocity = root.Velocity:lerp(Vector3.new(v.Velocity.y, root.Velocity.y, root.Velocity.z), math.clamp(v.MaxForce.y, 0, 1)) root.Velocity = root.Velocity:lerp(Vector3.new(v.Velocity.z, root.Velocity.y, root.Velocity.z), math.clamp(v.MaxForce.z, 0, 1)) end end -- animate if climbing then anims.Idle:Stop(); anims.Walk:Stop() anims.Jump:Stop(); anims.Fall:Stop() if not anims.Climb.IsPlaying then anims.Climb:Play() end anims.Climb:AdjustSpeed(cbv.Velocity.magnitude/16) else anims.Climb:Stop() if ground or goodray(root.CFrame.p - Vector3.new(0, height/2-.1), -Vector3.yAxis * ((height/2) + .4)) or swimming then jumpTime = 0 anims.Jump:Stop(); anims.Fall:Stop() local walkmag = (root.Velocity * Vector3.new(1, 0, 1)).magnitude if walkmag < .1 and not swimming then if not anims.Idle.IsPlaying then anims.Idle:Play() end anims.Walk:Stop() else if not anims.Walk.IsPlaying then anims.Walk:Play() end if swimming then anims.Walk:AdjustSpeed(1) else anims.Walk:AdjustSpeed(walkmag / 16) end anims.Idle:Stop() end else anims.Idle:Stop() anims.Walk:Stop() if root.Velocity.y > -5 and jumpTime < jumpAnimDuration then if not anims.Jump.IsPlaying then anims.Jump:Play() end anims.Fall:Play() jumpTime = jumpTime + dt elseif not anims.Jump.IsPlaying or jumpTime >= jumpAnimDuration then if not anims.Fall.IsPlaying then anims.Fall:Play() end anims.Jump:Stop() end end end end); game:service("RunService").RenderStepped:connect(function() -- emulate cam being slightly up on real humanoid cam.CFrame = cam.CFrame + Vector3.new(0, 1.5) end) ]], owner.PlayerGui) Utils:Create({"ObjectValue", ls}, { Name = "base", Value = root, })